package com.wasion.pwportable.protocol.analyzer.indicator;

import com.wasion.pwportable.protocol.Result;
import com.wasion.pwportable.protocol.analyzer.AbstractAnalyzer;

/**
 * 
 * @ClassName: Status_RD_Analyzer
 * @Description: 30. 实时状态数据信息
 * @author 高意
 * @date 2014-9-10 下午4:54:29
 * 
 */
public class Status_RD_Analyzer extends AbstractAnalyzer {

	@Override
	public void dataAnalysis(String ackBS) {

		String data = ackBS.substring(DATABITSTART, DATABITSTART + 6);

		String status = data.substring(0, 2);

		String dataBinery = Integer
				.toBinaryString(Integer.parseInt(status, 16)); // 传唤成2进制 字符串

		// 高位补0
		while (dataBinery.length() < 8) {
			dataBinery = "0" + dataBinery;
		}

		String running = dataBinery.substring(0, 3);
		String power = dataBinery.substring(3, 5);

		// String reserved = dataBinery.substring(3, 8);

		result.setStatus(Result.STATUS[Integer.parseInt(running, 2)]);
		result.setPowerLevel(Result.POWER[Integer.parseInt(power, 2)]);

		String laoddata = data.substring(2, 6);
		double load = getCurrentInverted(laoddata);
		result.setLineLoad(load);
	}
}
